package xyz.renyumeng.xkm.order.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static xyz.renyumeng.xkm.rabbitMQ.RabbitMqConstant.*;


/**
 * @author renyumeng
 * @date Created in 11:02 2023/7/4
 */

@Configuration
public class ProductQueueConfig {


    @Bean
    public Queue productSaveQueue() {
        return new Queue(PRODUCT_QUEUE, true);
    }

    @Bean
    DirectExchange productDirectExchange() {
        return new DirectExchange(PRODUCT_EXCHANGE, true, false);
    }

    @Bean
    Binding bindingProductDeListDirect() {
        return BindingBuilder
                .bind(productSaveQueue())
                .to(productDirectExchange())
                .with(PRODUCT_DE_LIST_ROUTING_KEY);
    }

    @Bean
    Binding bindingProductListDirect() {
        return BindingBuilder
                .bind(productSaveQueue())
                .to(productDirectExchange())
                .with(PRODUCT_LIST_ROUTING_KEY);
    }

}
